package com.ldzy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ldzy.dao.ToolDao;
import com.ldzy.domain.PageResult;
import com.ldzy.domain.Record;
import com.ldzy.domain.Tool;
import com.ldzy.service.ToolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ToolServiceImpl implements ToolService {
    @Autowired
    private ToolDao toolDao;

    @Override
    public PageResult selectNewBooks(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<Tool> page=toolDao.selectNewBooks();
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public int edit(Tool tool) {
         return toolDao.edit(tool);
    }

    public Tool findById(String id){
        return toolDao.findById(id);
    }

    @Override
    public int returnConfirm(Tool tool) {
        //        int j=recoudDao.add(); 到借阅记录表中插入一条记录：
        return toolDao.returnConfirm(tool);
    }

    @Override
    public Page<Tool> findByBookWithUpLoadTimeDesc(Tool tool) {
        return toolDao.findByBookWithUpLoadTimeDesc(tool);
    }

    @Override
    public List<Tool> findByName(String name){
        return toolDao.findByName(name);
    }
    @Override
    public List<Tool> findbyName(String name){
        return toolDao.findByName(name);
    }

    @Override
    public Page<Record> findByBook(Record record) {
        return toolDao.findByBook(record);
    }

    }
